package cn.crap.utils;

import com.itextpdf.text.BaseColor;
import com.itextpdf.text.DocumentException;
import com.itextpdf.text.Font;
import com.itextpdf.text.FontProvider;
import com.itextpdf.text.pdf.BaseFont;

import java.io.IOException;

public class ChinaFont implements FontProvider {

    @Override
    public boolean isRegistered(String fontname) {
        return false;
    }

    public Font getFont(String fontname, String encoding, boolean embedded, float size, int style, BaseColor color) {

        try {
            BaseFont bfChinese;
            bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED);
            return new Font(bfChinese, size, style, color);
        } catch (DocumentException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return null;
    }
}